# Copyright (c) 2009 Daropia Project (www.daropia.org)
#
# This file is part of Daropia and is available under the terms
# of the GNU General Public Licence version 2.0 or later.


# Adds some tables for the forum : Forums, Topics and Posts

Class.new(Sequel::Migration) do

    def up
        create_table(:forums) do
            primary_key :id
            String :name
            String :image
            String :description
            Integer :message_count, :default => 0
        end

        create_table(:topics) do
            primary_key :id
            String :title
            foreign_key :forum_id
        end

        create_table(:posts) do
            primary_key :id
            foreign_key :user_id
            foreign_key :topic_id
            String :text
        end
    end

    def down
        drop_table(:forums)
        drop_table(:topics)
        drop_table(:posts)
    end

end
